home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 126-150 / disk_147 / sys / atari / atari.zoo / term.c < prev    next >
C/C++ Source or Header  |  1988-07-25  |  3KB  |  147 lines

  1. /* term.c -- screen output code for Atari ST terminal
  2.  *
  3.  * author :  Sandra Loosemore (based on an earlier version by dec-rec!conroy)
  4.  * date   :  24 Oct 1987
  5.  * changes:  Marion Hakanson -- Jan 1988
  6.  *
  7.  * This code simulates scrolling regions by using the
  8.  * insert line and delete line functions. Should display
  9.  * handling be taught about this. Based on Rich's code
  10.  * for the Heath H19.
  11.  */
  12.  
  13. #include    "..\..\def.h"
  14.  
  15. #define    BEL    0x07            /* BEL character.        */
  16. #define    ESC    0x1B            /* ESC character.        */
  17. #define    LF    0x0A            /* Line feed.            */
  18.  
  19. extern int ttrow;
  20. extern int ttcol;
  21. extern int tttop;
  22. extern int ttbot;
  23. extern int tthue;
  24.  
  25. int    tceeol    =    2;        /* Costs.            */
  26. int    tcinsl, tcdell;            /* Set in ttyio.c:ttopen()    */
  27.  
  28.  
  29. /* Move the cursor to the specified origin 0 row and column position.  Try
  30.  *    to optimize out extra moves; redisplay may have left the cursor in 
  31.  *    the right location on the screen last time.
  32.  */
  33.  
  34. VOID ttmove(row, col)
  35. {   if (ttrow!=row || ttcol!=col) {
  36.     if (row > nrow)
  37.         row = nrow;
  38.     if (col > ncol)
  39.         col = ncol;
  40.     ttputc(ESC);
  41.     ttputc('Y');
  42.     ttputc(row+' ');
  43.     ttputc(col+' ');
  44.     ttrow = row;
  45.     ttcol = col;
  46.     }
  47.     }
  48.  
  49.  
  50. /* Erase to end of line. */
  51.  
  52. VOID tteeol()
  53. {   ttputc(ESC);
  54.     ttputc('K');
  55.     }
  56.  
  57.  
  58. /* Erase to end of page. */
  59.  
  60. VOID tteeop()
  61. {   ttputc(ESC);
  62.     ttputc('J');
  63.     }
  64.  
  65.  
  66. /* Make a noise.  */
  67.  
  68. VOID ttbeep()
  69. {   ttputc(BEL);
  70.     ttflush();
  71.     }
  72.  
  73.  
  74. /* Insert nchunk blank line(s) onto the screen, scrolling the last line on
  75.  *    the screen off the bottom. This is done with a cluster of clever 
  76.  *    insert and delete commands, because there are no scroll regions.
  77.  */
  78.  
  79. VOID ttinsl(row, bot, nchunk)
  80. {   register int    i;
  81.     if (row == bot) {
  82.     ttmove(row, 0);
  83.     tteeol();
  84.     return;
  85.     }
  86.     ttmove(1+bot-nchunk, 0);
  87.     for (i=0; i<nchunk; i++) {
  88.     ttputc(ESC);
  89.     ttputc('M');
  90.     }
  91.     ttmove(row, 0);
  92.     for (i=0; i<nchunk; i++) {
  93.     ttputc(ESC);
  94.     ttputc('L');
  95.     }
  96.     ttrow = row;
  97.     ttcol = 0;
  98.     }
  99.  
  100.  
  101. /* Delete nchunk line(s) at "row", replacing the bottom line on the screen
  102.  *    with a blank line. This is done with a crafty sequences of insert 
  103.  *    and delete line sequences since there is no scroll region.  The
  104.  *     presence of the echo area makes a boundary condition go away.
  105.  */
  106.  
  107. VOID ttdell(row, bot, nchunk)
  108. {   register int    i;
  109.     if (row == bot) {
  110.     ttmove(row, 0);
  111.     tteeol();
  112.     return;
  113.     }
  114.     ttmove(row, 0);
  115.     for (i=0; i<nchunk; i++) {
  116.     ttputc(ESC);
  117.     ttputc('M');
  118.     }
  119.     ttmove(1+bot-nchunk,0);
  120.     for (i=0; i<nchunk; i++) {
  121.     ttputc(ESC);
  122.     ttputc('L');
  123.     }
  124.     ttrow = 1+bot-nchunk;
  125.     ttcol = 0;
  126.     }
  127.  
  128.  
  129. /* Set display color.  Normal video is text color.  Reverse video is used
  130.  *     for the mode line.
  131.  */
  132.  
  133. VOID ttcolor(color)
  134.     register int color;
  135. {   if (color != tthue) {
  136.     if (color == CTEXT) {        /* Normal video.    */
  137.         ttputc(ESC);
  138.         ttputc('q');
  139.         } 
  140.     else if (color == CMODE) {    /* Reverse video.    */
  141.         ttputc(ESC);
  142.         ttputc('p');
  143.         }
  144.     tthue = color;
  145.     }
  146.     }
  147.